package com.kdtech.entity.data.save;

import java.io.IOException;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import org.ansj.app.keyword.Keyword;

import com.kdtech.utils.SerializeUtils;
/**
 * 用于建索引的数据
 * @author kd-12
 *
 */
public class IndexMeta implements Serializable{
	/**
	 * 信息的Url
	 */
	private String url;
	/**
	 * 1: 新闻 2：视频 3:论坛 4：问答/知道 5：平媒 6：博客
	 */
	private Integer type;
	/**
	 * 标题 (Length<=100)
	 */
	private String title;
	/**
	 * 正文
	 */
	private String content;
	/**
	 * 摘要
	 */
	private String TextSummary;
	/**
	 * 信息的日期
	 */
	private Long date;
	/**
	 * 来源
	 */
	private Integer source;

	/**
	 * 网站入口ID
	 */
	private Integer entryId;
	/**
	 * 地域属性
	 */
	private Integer AddressValue;
	/**
	 * 作者
	 */
	private String author;
	/**
	 * 作者Id
	 */
	private Integer authorId;
	
	/**
	 * 是否重点关注信息 0 普通 1 {1}类重点 2 {2}类重点
	 */
	private Integer InforLeve = 0;
	/**
	 * 根据文章标题和内容得到的主题关键字列表
	 */
	private byte[] keywordMeta=null;
     /**
      * 存储的网页快照原始html
      */
	private byte[] htmlBytes=null;
	/**
	 * 正负面属性 0负面 1中性 2正面
	 */
	private int PosNeg=1;
	/**
	 * 标题的simHash
	 */
	private Long title_simHash;
	/**
	 * 标题的词的数量
	 */
	private int titleTermLength;
	/**
	 * 内容的simHash
	 */
	private Long cent_simHash;
	/**
	 * 内容的词的数量
	 */
	private int centTermLength;
	
	
	/**
	 * 点击数/顶
	 */
	private Integer clickNum;
	/**
	 * 评论数/跟帖数
	 */
	private Integer commentNum;
	
	/**
	 * 转发数
	 */
	private Integer forwardNum;
	
	
	public Integer getForwardNum() {
		return forwardNum;
	}
	public void setForwardNum(Integer forwardNum) {
		this.forwardNum = forwardNum;
	}
	/**
	 * 更新信息属性地址
	 */
	private String updateUrl = null;
	public Long getTitle_simHash() {
		return title_simHash;
	}
	public Long getCent_simHash() {
		return cent_simHash;
	}
	public Integer getClickNum() {
		return clickNum;
	}
	public void setClickNum(Integer clickNum) {
		this.clickNum = clickNum;
	}
	public Integer getCommentNum() {
		return commentNum;
	}
	public void setCommentNum(Integer commentNum) {
		this.commentNum = commentNum;
	}
	public String getUpdateUrl() {
		return updateUrl;
	}
	public void setUpdateUrl(String updateUrl) {
		this.updateUrl = updateUrl;
	}
	public void setTitle_simHash(Long title_simHash) {
		this.title_simHash = title_simHash;
	}
	public void setCent_simHash(Long cent_simHash) {
		this.cent_simHash = cent_simHash;
	}
	public String getUrl() {
		return url;
	}
	public void setUrl(String url) {
		this.url = url;
	}
	public Integer getType() {
		return type;
	}
	public void setType(Integer type) {
		this.type = type;
	}
	public String getTitle() {
		return title;
	}
	public void setTitle(String title) {
		this.title = title;
	}
	public String getContent() {
		return content;
	}
	public void setContent(String content) {
		this.content = content;
	}
	public String getTextSummary() {
		return TextSummary;
	}
	public void setTextSummary(String textSummary) {
		TextSummary = textSummary;
	}
	public Long getDate() {
		return date;
	}
	public void setDate(Long date) {
		this.date = date;
	}
	public Integer getSource() {
		return source;
	}
	public void setSource(Integer source) {
		this.source = source;
	}
	public Integer getEntryId() {
		return entryId;
	}
	public void setEntryId(Integer entryId) {
		this.entryId = entryId;
	}
	public Integer getAddressValue() {
		return AddressValue;
	}
	public void setAddressValue(Integer addressValue) {
		AddressValue = addressValue;
	}
	public String getAuthor() {
		return author;
	}
	public void setAuthor(String author) {
		this.author = author;
	}
	public Integer getAuthorId() {
		return authorId;
	}
	public void setAuthorId(Integer authorId) {
		this.authorId = authorId;
	}
	public Integer getInforLeve() {
		return InforLeve;
	}
	public void setInforLeve(Integer inforLeve) {
		InforLeve = inforLeve;
	}
	public byte[] getKeywordMeta() {
		return keywordMeta;
	}
	public void setKeywordMeta(byte[] keywordMeta) {
		this.keywordMeta = keywordMeta;
	}
	public byte[] getHtmlBytes() {
		return htmlBytes;
	}
	public void setHtmlBytes(byte[] htmlBytes) {
		this.htmlBytes = htmlBytes;
	}
	public int getPosNeg() {
		return PosNeg;
	}
	public void setPosNeg(int posNeg) {
		PosNeg = posNeg;
	}

	public int getTitleTermLength() {
		return titleTermLength;
	}
	public void setTitleTermLength(int titleTermLength) {
		this.titleTermLength = titleTermLength;
	}

	public int getCentTermLength() {
		return centTermLength;
	}
	public void setCentTermLength(int centTermLength) {
		this.centTermLength = centTermLength;
	}
	public void setKeywordMetaConvert(List<Keyword> keyword) {
		byte[] serialize = null;
		if(keyword!=null && keyword.size()>0){
			List<KeywordMeta> listKeyword  =  new ArrayList<KeywordMeta>();
			for (Keyword kw : keyword) {
				KeywordMeta tkw = new KeywordMeta();
				tkw.setName(kw.getName());
				tkw.setFreq(kw.getFreq());
				tkw.setScore(kw.getScore());
				listKeyword.add(tkw);
			}
			try {
				serialize = SerializeUtils.serialize((Serializable) listKeyword);
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		this.keywordMeta = serialize;
	}
	public List<KeywordMeta> getKeywordMetaEntity() {
		try {
			if(keywordMeta!=null){
				Object object=SerializeUtils.deserialize(keywordMeta);
				return (List<KeywordMeta>) object;
			}
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return null;
	}
}
